/**
  * Created by ZWK on 2017/5/11.
  */
import java.util.Locale
import java.text.SimpleDateFormat
import java.util.Date

object timeParse {
    def main(args: Array[String]): Unit = {
        val tm = "[08/May/2017:22:33:44 +0800]"
        val c =tm.replaceAll("\\[([^\\]]*)\\]", "$1").split(" ")
        val loc = new Locale("en")
        val fm = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",loc)
        val sdf = new SimpleDateFormat("yyMMddHHmm")

        val dt2 = fm.parse(c(0))
        //获取日志时间戳
        val logTime =dt2.getTime()
        println("获取日志时间:"+logTime)
        //获取日志时区
        val timeZone =c(1)
        println("获取日志时区:"+timeZone)
        //获取时间: yyMMddHHmm
        val date = new Date(logTime)
        val tim = sdf.format(date).toString
        println("获取时间:"+tim)

        //获取日期：yyMMdd
        val tim1 =tim.substring(0,6)
        println("获取日期:"+tim1)

        //获取小时
        val tim2 =tim.substring(6,8)
        println("获取小时:"+tim2)
        //获取分钟
        val tim3 =tim.substring(8,10)
        println("获取分钟:"+tim3)
      //获取分区

       println("获取每5个分钟一个批次):"+getPartition(tim3))
    }

    //)获取每5个分钟一个批次
    def getPartition(tempStr:String): Int ={
        val temp =Integer.parseInt(tempStr)
        temp/5*5
    }
}
